package google.util;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

/**
 * Created by zhongwei on 2017/1/14.
 */
public class DownLoader {

    public static String downLoad(HttpClient client, HttpGet get) {
        HttpResponse response = null;
        String content = "";
        try {
            response = client.execute(get);
            content = EntityUtils.toString(response.getEntity());
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (response != null) {
                EntityUtils.consumeQuietly(response.getEntity());
            }
        }
        return content;
    }
}
